package com.hilinos.gb.gb28181.utils;

import java.net.DatagramPacket;
import java.net.DatagramSocket;
import java.net.InetAddress;

import com.hilinos.gb.gb28181.repository.mysql.mapper.po.Host;

import lombok.SneakyThrows;
import lombok.extern.slf4j.Slf4j;

@Slf4j
public class UdpClient {

    @SneakyThrows
    public static void send(byte[] content, Host host) {
        try (DatagramSocket socket = new DatagramSocket()) {
            DatagramPacket data = new DatagramPacket(content, content.length, InetAddress.getByName(host.getIp()),
                    host.getPort());
            socket.send(data);
        }
    }

}
